package com.mifengkong.frtools.http.request.cloudapi;

import com.mifengkong.frtools.util.FRString;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by jiangyongxing on 2017/9/27.
 * 描述：
 */

public class FRCloudAPIUtil {

    private static final class SingletonHolder {
        private static final FRCloudAPIUtil INSTANCE = new FRCloudAPIUtil();
    }

    public static FRCloudAPIUtil getInstance() {
        return FRCloudAPIUtil.SingletonHolder.INSTANCE;
    }

    private FRCloudAPIUtil() {

    }

    private Map<String, String> baseUrlArray = new HashMap<>();
    private Map<String, String> appKeyArray = new HashMap<>();
    private Map<String, String> secretKeyArray = new HashMap<>();

    public FRCloudAPIUtil setBaseUrl(String key, String baseUrl) {
        if (!FRString.isEmpty(key, baseUrl)) {
            baseUrlArray.put(key, baseUrl);
        }
        return this;
    }

    public FRCloudAPIUtil setAppKey(String key, String appKey) {
        if (!FRString.isEmpty(key, appKey)) {
            appKeyArray.put(key, appKey);
        }
        return this;
    }

    public FRCloudAPIUtil setSecretKey(String key, String secretKey) {
        if (!FRString.isEmpty(key, secretKey)) {
            secretKeyArray.put(key, secretKey);
        }
        return this;
    }

    public String getBaseUrl(String key) {
        if (FRString.isEmpty(key)) {
            return FRString.EMPTY_STRING;
        }
        return baseUrlArray.get(key);
    }

    public String getAppKey(String key) {
        if (FRString.isEmpty(key)) {
            return FRString.EMPTY_STRING;
        }
        return appKeyArray.get(key);
    }

    public String getSecretKey(String key) {
        if (FRString.isEmpty(key)) {
            return FRString.EMPTY_STRING;
        }
        return secretKeyArray.get(key);
    }
}